package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.aop.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {


    /**
     * 菜品新增
     * @param dish
     */
    @AutoFill(OperationType.INSERT)
    void add(Dish dish);

    /**
     * 菜品分页查询
     * @param pageDTO
     * @return
     */
    Page<DishVO> pageQuery(DishPageQueryDTO pageDTO);


    /**
     *删除状态未启售的
     * @param ids
     * @param enable
     * @return
     */
    int getCountByStatus(List<Long> ids, Integer enable);

    /**
     * 菜品、套餐关联
     * @param ids
     * @return
     */
    int getDishAndSetmeal(List<Long> ids);


    /**
     * 批量删除菜品表
     * @param ids
     */
    void deleteDish(List<Long> ids);


    /**
     * 查询菜品id
     * @param id
     * @return
     */
    Dish getId(Long id);

    /**
     * 菜品修改
     * @param dish
     */
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);


  /*  *//**
     * 根据分类id查询菜品
     * @param categoryId
     * @return
     *//*
    List<Dish> getByCategoryId(Long categoryId);*/



    List<Dish> getByCategoryId(@Param("categoryId") Long categoryId, @Param("status") Integer status);



}
